home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
simple6a
/
module1.bas
< prev
next >
Wrap
BASIC Source File
|
1999-09-22
|
2KB
|
62 lines
Attribute VB_Name = "Module1"
'Declare the Public variables needed for the game to work
Public Sqa As Integer, Sqb As Integer, X As Integer, Y As Integer
Sub HideAll()
Dim I As Integer
'Hide all pieces, if they aren't already hidden
For I = 0 To 80
If Form1.Picture1(I).Visible <> False Then Form1.Picture1(I).Visible = False
Next I
End Sub
Sub Start()
Dim I As Integer, J As Integer, A As Integer
'Calculate the piece dimensions. X is the piece's Width
'and Y is the piece Height
X = Form1.Picture2.ScaleWidth / Sqa
Y = Form1.Picture2.ScaleHeight / Sqb
'Set the mouse pointer to a hour glass
Screen.MousePointer = 11
'Clear the form, disable the shuffle option, clear the
'PictureBox container and make it invisible
'Form1.Cls
Form1.mnuShuffle.Enabled = True
Form1.Picture2.Cls
Form1.Picture2.Visible = False
'Now start creating each piece of the puzzle
For I = 0 To Sqa - 1
For J = 0 To Sqb - 1
A = I * Sqb + J
'Save its correct position in the picture's Tag property
Form1.Picture1(A).Tag = Format(I * X, "@@@@@@@") & Format(J * Y, "@@@@@@@")
'Set its dimensions
Form1.Picture1(A).Width = X
Form1.Picture1(A).Height = Y
'Paint the correct image on the piece and make it visible
Form1.Picture1(A).PaintPicture Form2.Image1.Picture, 0, 0, X, Y, I * Form2.Image1.Width / Sqa, J * Form2.Image1.Height / Sqb, Form2.Image1.Width / Sqa, Form2.Image1.Height / Sqb
Form1.Picture1(A).Visible = True
Next J
Next I
'Make the PictureBox container visible and set the mouse
'pointer to the default pointer
Form1.Picture2.Visible = True
Screen.MousePointer = 0
'Shuffle the pieces
Shuffle
End Sub
Sub Shuffle()
Dim I As Integer, J As Integer
'Move the pieces 150 times so that they are correctly
'shuffled
For I = 1 To 150
DoEvents
'Select a random piece
J = Int(Rnd * Sqb * Sqa)
'Position it in a random position
Form1.Picture1(J).Left = Int(Rnd * Form1.ScaleWidth - X / 2)
Form1.Picture1(J).Top = Int(Rnd * Form1.ScaleHeight - Y / 2)
Next I
End Sub